/**
 * @ClassName LC2710 移除字符串中的尾随零
 * @Author ykx
 * @Date 2024/6/29 8:42
 * @Version 1.0
 */
public class LC2710 {
    public static void main(String[] args) {
        LC2710 lc2710 = new LC2710();
        System.out.println(lc2710.removeTrailingZeros("51230100"));
    }

    public String removeTrailingZeros(String num) {
        int length = num.length() - 1;
        for (; length >= 0; length--) {
            if (num.charAt(length) != '0') {
                break;
            }
        }
        return num.substring(0, length + 1);
    }

}
